<template>
  <div>
    <div>
      <el-table :data="tableData" border style="width: 100%" @selection-change="handleSelectionChange">
        <el-table-column prop="ID" label="序号" width="60">
          <template slot-scope="scope">{{scope.$index+1}}</template>
        </el-table-column>
        <el-table-column prop="name" label="姓名"> </el-table-column>      
        <el-table-column prop="hospital_name" label="医院"></el-table-column>
        <el-table-column prop="work_time" label="工作时间"></el-table-column>
        <el-table-column prop="skill" label="擅长"></el-table-column>
        <el-table-column prop="tui" label="是否认证">
          <template  slot-scope="scope">
            <span style="color:#67c23a" v-if="scope.row.status==1">通过</span>
            <span style="color:red" v-if="scope.row.status==2">审核不通过</span>
            <span v-if="scope.row.status==0">未审核</span>
          </template>
        </el-table-column>
        <el-table-column prop="page_view" label="浏览量"></el-table-column>
        <el-table-column prop="tui" label="状态">
          <template  slot-scope="scope">
            <span style="color:#67c23a" v-if="scope.row.status==1">上线</span>
            <span v-else>下线</span>
          </template>
        </el-table-column>
        <el-table-column width="150" label="操作">
          <template slot-scope="scope">
            <div v-if="userRole.HPT_DT_1704001">
              <el-button class="addBtn" type="primary" @click="addUserFun(scope.row)">查看</el-button>
              <el-button class="addBtn" type="danger" @click="editStatus(scope.row.id,2)" v-if="scope.row.status==1">下线</el-button>
              <el-button class="addBtn" type="success" @click="editStatus(scope.row.id,1)" v-else>上线</el-button>
            </div>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <div class="block">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="currentPage4"
          :page-sizes="[10, 20, 30, 50]"
          :page-size="10"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total">
        </el-pagination>
    </div>
  </div>
</template>

<script>
  import Http from '@/Http/Http'
  import getTime from '@/Http/getTime'
  export default {
    data() {
      return {
        userRole:JSON.parse(sessionStorage.getItem('userSolt')),
        DoctorStatus:false,
        value:'关注',
        dataPush:'',
        doctData:'',
        total:0,
        currentPage4: 1,//分野  
        page:1,
        pageSize:10,
        sheachValue:'',
        tableData:[]
      }
    },
    props:['navStatus'],
    created(){
      this.getlist()
    },
    methods: {
      getlist(){
        const obj = {
          "pageIndex":this.page,
          "pageSize":this.pageSize,
        };
        if (this.navStatus != -1){
          obj.status = this.navStatus
        }
        if (this.sheachValue) {
          obj.keyword = this.sheachValue
        };
        Http.getDoctorAttestList(obj)
        .then( res => {
          this.tableData = res.data.data.rows;
          this.total = res.data.data.total;
        })
        .catch( error => {
          
        })
        this.DoctorStatus = false
      },
      //添加用户
      addUserFun(row) {
        this.$emit('addUserFun',row)
      },
      colseFun(){
        this.DoctorStatus = false
      },
     
      editStatus(id,status) {
        let txt;
        status == 1 ? txt = '上线' : txt = '下线';
        this.$confirm(`确认 ${txt} 改医生吗？`)
        .then(_ => {
          const obj ={
            "status":status,
            "id":id
          };
          Http.AuditDoctor(obj)
          .then( res => {
            
            if (res.data.code == 200) {
               this.getlist()
              this.$message.success('提交成功')
            } else if(res.data.code == -1003) {
              this.$message.error(`请求失败原因：${res.data.message}`)
              this.$router.push('/')
            } else {
              this.$message.error('提交失败')}
          })
          .catch( error => {
            
            this.$message.error('服务器请求失败')
          })
        })
        .catch(_ => {
          //取消部分
          
        });
      },
      //选择 推荐
      handleSelectionChange() {
        
      },
          //分页
      handleSizeChange(val) {
        this.pageSize = val;
        this.getlist()
        
      },
      handleCurrentChange(val) {
        this.page = val;
        this.getlist()
        
      },
    }
  }
</script>
<style  scoped>
.box{
  border-bottom:1px solid red;
}
    .test{
        border:1px solid #ccc;
    }
    .drag-item{
        width: 200px;
        height: 50px;
        line-height: 50px;
        margin: auto;
        position: relative;
        
        background: #ddd;
        margin:20px 5px;
    }
    .ghostClass{
        opacity: 1;
    }
    .bottom{
        width: 200px;
        height: 50px;
        position: relative;
        background: blue;
        top:2px;
        left: 2px;
        transition: all .5s linear;
    }
</style>
